home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hardcore Visual Basic 5.0 (2nd Edition)
/
Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso
/
Code
/
StackLst.cls
< prev
next >
Wrap
Text File
|
1997-06-14
|
1KB
|
49 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "CStackLst"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Implements IStack
Private lnkHead As CLink
Private c As Long
Private Sub IStack_Push(vArg As Variant)
' Create a temporary link with new value
Dim lnkTmp As New CLink
Set lnkTmp = New CLink
If IsObject(vArg) Then
Set lnkTmp.Item = vArg
Else
lnkTmp.Item = vArg
End If
' Insert it at head
Set lnkTmp.NextLink = lnkHead
Set lnkHead = lnkTmp
c = c + 1
End Sub
Private Function IStack_Pop() As Variant
' Can't pop from empty list
If lnkHead Is Nothing Then Exit Function
' Copy head value and remove the link
If IsObject(lnkHead.Item) Then
Set IStack_Pop = lnkHead.Item
Else
IStack_Pop = lnkHead.Item
End If
Set lnkHead = lnkHead.NextLink
c = c - 1
End Function
Private Property Get IStack_Count() As Long
IStack_Count = c
End Property